package com.ai.manager.edu.cms.acquisition;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.ai.common.model.Pagination;
import com.ai.dao.edu.cms.acquisition.AcquisitionConfigMapper;
import com.ai.model.edu.cms.acquisition.AcquisitionConfig;
import com.ai.model.edu.cms.acquisition.dto.AcquisitionConfigDTO;
import com.ai.model.edu.cms.acquisition.vo.AcquisitionConfigVO;

@Component
public class AcquisitionConfigManager {

    @Resource
    private AcquisitionConfigMapper acquisitionConfigMapper;
    
    /**
     * Description  ： 根据DTO查询栏目分页信息<br>
     * 
     * wumc
     * @param acquisitionConfigDTO
     * @return
     * @since
     *
     */
    public Pagination<AcquisitionConfigVO> findAcquisitionConfigPageByDTO(AcquisitionConfigDTO acquisitionConfigDTO) {
        Pagination<AcquisitionConfigVO> acquisitionConfigPg = new Pagination<AcquisitionConfigVO>();
        
        //获取条件查询的总数
        int count = acquisitionConfigMapper.countAcquisitionConfigPageByDTO(acquisitionConfigDTO);
        acquisitionConfigPg.setTotal(count);
        if(count == 0) {
            List<AcquisitionConfigVO> acquisitionConfigList = new ArrayList<AcquisitionConfigVO>();
            acquisitionConfigPg.setRows(acquisitionConfigList);
        } else {
            List<AcquisitionConfigVO> acquisitionConfigList 
                    = acquisitionConfigMapper.findAcquisitionConfigPageByDTO(acquisitionConfigDTO);
            acquisitionConfigPg.setRows(acquisitionConfigList);
        }
        return acquisitionConfigPg;
    }
    
    /**
     * Description  ： 新增采集配置<br>
     * 
     * wumc
     * @param acquisitionConfig
     * @return
     * @since
     *
     */
    public int saveAcquisitionConfig(AcquisitionConfig acquisitionConfig) {
        return acquisitionConfigMapper.saveAcquisitionConfig(acquisitionConfig);
    }

    /**
     * Description  ： 更新采集配置<br>
     * 
     * wumc
     * @param acquisitionConfig
     * @return
     * @since
     *
     */
    public int updateAcquisitionConfig(AcquisitionConfig acquisitionConfig) {
        return acquisitionConfigMapper.updateAcquisitionConfig(acquisitionConfig);
    }

    /**
     * Description  ： 根据ID查询配置信息<br>
     * 
     * wumc
     * @param configId
     * @return
     * @since
     *
     */
    public AcquisitionConfigVO queryAcquisitionConfigById(Long configId) {
        return acquisitionConfigMapper.queryAcquisitionConfigById(configId);
    }
}
